const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    const content = [];
    for(let i = 0; i < 40; i++) content.push({
        id: `${i}`,
        brandName: `brandName${i}`,
        targetYear: `${i}`,
        targetVersion: `targetVersion${i}`,
        countryName: '中国',
        manufacturerName: 'manufacturerName',
        status: 1,
        approverName: 'approverName',
        approveTime: '2020-01-09T06:45:51.499Z',
        approverOpinion: 'approverOpinion',
        rowVersion: 'string',
        options: [
            'submit',
            'abandon',
            'approve'
        ]
    });

    res.json({
        message: 'ok',
        payload: {
            content,
            totalElements: 40,
        }
    });
});

router.get('/:id', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            id: '001',
            targetYear: 'targetYear',
            targetVersion: 'targetVersion',
            brandName: 'brandName',
            countryName: 'countryName',
            manufacturerName: 'manufacturerName',
            approverName: 'approverName',
            approveTime: '2020-01-09T07:23:51.295Z',
            approverOpinion: 'approverOpinion',
            status: 1,
            options: [
                'submit',
                'abandon',
                'approve'
            ],
            rowVersion: 'string',
            annualSalesTargetDetails: [
                {
                    id: 'id001',
                    assembleMethod: 1,
                    modelCode: 'modelCode001',
                    modelName: 'modelName',
                    engineCylinder: 'engineCylinder001',
                    engineModelName: 'engineModelName001',
                    gearboxModel: 'gearboxModel001',
                    transmission: 'transmission001',
                    version: 'version',
                    productCodeMaterialGroup: 'productCodeMaterialGroup',
                    referenceProductCodeMaterialGroup: 'referenceProductCodeMaterialGroup',
                    kdBOMCode: 'kdBOMCode',
                    referenceKDBOMCode: 'referenceKDBOMCode',
                    firstEditionMaterial: 'firstEditionMaterial',
                    powertrainMaterial: 'powertrainMaterial',
                    engineMaterial: 'engineMaterial',
                    gearboxMaterial: 'gearboxMaterial',
                    researchProduction: 'researchProduction',
                    driveMode: 'driveMode',
                    isExpectedList: true,
                    expectedListDate: '2020-01-08T07:58:21.810Z',
                    januaryTarget: 1,
                    februaryTarget: 2,
                    marchTarget: 3,
                    aprilTarget: 4,
                    mayTarget: 5,
                    juneTarget: 6,
                    julyTarget: 7,
                    augustTarget: 8,
                    septemberTarget: 9,
                    octoberTarget: 10,
                    novemberTarget: 11,
                    decemberTarget: 12,
                    targetSum: 654,
                },
            ],
        },
        totalElements: 40,
    });
});

router.put('/:id/submit', (req, res) => {
    res.json({
        message: '提交'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废'
    });
});

router.put('/:id/pass', (req, res) => {
    res.json({
        message: '审核通过'
    });
});
router.put('/:id/reject', (req, res) => {
    res.json({
        message: '驳回'
    });
});
router.post('/import', async(req, res) => {
    res.json({
        message: '导入'
    });
});
router.get('/importTemp', (req, res) => {
    res.json({
        message: '导出'
    });
});
router.get('/export', (req, res) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});
module.exports = router;
